package com.hmall.common.util;

public class ThreadLocalUtils {
    // 线程容器对象,每一个线程都有自己的对象,此对象不共享
    private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
    //private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
    //private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
    //private static ThreadLocal<String> threadLocal = new ThreadLocal<String>();

    // 调用此方法往线程对象上存放数据信息
    public static void setValue(String msg){
        threadLocal.set(msg);
    }

    // 调用此方法从线程对象上获取数据信息
    public static String getValue(){
        String msg = threadLocal.get();
        return msg;
    }
}
